home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17719 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  89 lines

  1. Path: server-b.cs.interbusiness.it!usenet
  2. From: albe@piw.it (Alberto Velo)
  3. Newsgroups: comp.lang.c++
  4. Subject: Need Help!
  5. Date: Tue, 16 Apr 1996 21:41:23 -0100
  6. Organization: Centro Servizi Interbusiness
  7. Message-ID: <TICdxQTC3c9e090yn@piw.it>
  8. Reply-To: albe@piw.it
  9. NNTP-Posting-Host: pittys16.gvo.it
  10. X-PGP-Fingerprint: BE C9 BE 39 20 8C A4 F2  22 FE 02 56 C3 31 51 F9
  11. X-Newsreader: Yarn for OS/2 v0.90
  12.  
  13. I have a problem I can't manage to solve.. perhaps you gurus might help me? :)
  14.  
  15. I have a class:
  16.  
  17. class Datiftp
  18. {
  19.    public:
  20.         char nome[MAXLEN], path[MAXLEN], sito[MAXLEN], 
  21.                 dir[MAXLEN], file[MAXLEN], logf[MAXSIZE];
  22.         Datiftp();
  23.         Datiftp(Datiftp &);
  24. };
  25.  
  26. and create an array of objects, with:
  27.  
  28. Datiftp *ftp;
  29.         ftp = new Datiftp [SESSIONS];
  30.         if (!ftp) error(NOMEMORY);
  31.  
  32. Then I play with the objects array, and at a certain point I have the function 
  33. copiafile(). Parms are a file name and another filename (the function moves the 
  34. file from current dir to another dir, for example file=pippo.zip and 
  35. newfile=c:\dir\subdir\pippo.zip).
  36. Function is called from within another member function, with:
  37.  
  38. copiafile(sesftp[n].file, tmp);
  39.  
  40. Where sesftp[n] is another array of objects of class DatiFtp, created like ftp 
  41. (see some lines up).
  42. This works, but only with the first object of the array (i.e. the first file I 
  43. use as parm)! The second time I get an error when I open the ofstream (i.e. 
  44. function exits with error(NOWRITEFILE).
  45.  
  46. void Dat::copiafile(char *file, char *newfile)  // copia file nella userdir
  47. {
  48. char c;
  49. ifstream in;
  50. in.open(file, ios::in | ios::binary);
  51.         if (!in) error(NOREADFILE);
  52.  
  53. ofstream out;
  54. out.open(newfile, ios::out | ios::binary);
  55.         if (!out) error(NOWRITEFILE);
  56.  
  57. while (!in.eof()) {
  58.         in.get(c);
  59.         if (!in.eof()) out.put(c);
  60. } /* endwhile */
  61.  
  62. in.close();
  63. out.close();
  64.  
  65. }
  66.  
  67. I tried using C syntax (FILE* instead of streams) or using direct "ofstream 
  68. out(newfile, ios::binary); ", but the result is still the same ;(
  69.  
  70. If anybody can help please answer in **E-MAIL**, since I don't have the time to
  71. follow the newsgroup every day.
  72.  
  73. -- 
  74. Bye,   AL!       
  75.  
  76.  Team OS/2 Italia WebMaster ---> MD1652@mclink.it
  77.  IBM DAP Member
  78.                                     E-mail :        albe@piw.it
  79.                                     Fidonet:        2:334/708.1
  80.  PGP Key available                  OS2net :        81:439/63.1
  81.                                     BBS    : Telnet bbs.piw.it (194.21.239.4)
  82.  
  83.   --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 
  84. - Craxi e' solo con se stesso
  85. - Quell'uomo continua a circondarsi delle persone sbagliate
  86.  
  87.                                 ElleKappa
  88.   --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 
  89.